package com.fesine.config;

import com.alibaba.dubbo.config.*;
import com.fesine.properties.ZkProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/9/14 22:57
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/9/14 22:57
 */
public class DubboBaseConfig {

    @Autowired
    private ZkProperties zkProperties;

    @Bean
    public RegistryConfig registry() {
        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setClient(zkProperties.getClient());
        registryConfig.setAddress(zkProperties.getAddress());
        registryConfig.setProtocol(zkProperties.getProtocol());
        registryConfig.setGroup(zkProperties.getGroup());
        return registryConfig;
    }

    @Bean
    public ApplicationConfig application() {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("batch-consumer");
        return applicationConfig;
    }

    //@Bean
    //public MonitorConfig monitorConfig() {
    //    MonitorConfig mc = new MonitorConfig();
    //    mc.setProtocol("registry");
    //    return mc;
    //}
    //
    //@Bean
    //public ReferenceConfig referenceConfig() {
    //    ReferenceConfig rc = new ReferenceConfig();
    //    rc.setMonitor(monitorConfig());
    //    return rc;
    //}

    @Bean
    public ProtocolConfig protocol() {
        ProtocolConfig protocolConfig = new ProtocolConfig();
        protocolConfig.setPort(zkProperties.getPort());
        return protocolConfig;
    }

    @Bean
    public ProviderConfig provider() {
        ProviderConfig providerConfig = new ProviderConfig();
        //providerConfig.setMonitor(monitorConfig());
        return providerConfig;
    }
}
